package com.xcq.mall.service.serviceImpl;

import com.xcq.mall.entity.Goods;
import com.xcq.mall.mapper.GoodsMapper;
import com.xcq.mall.service.IGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CQ.Xi
 * @since 2022-10-20
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
    @Autowired
    GoodsMapper goodsMapper;

//    public Integer getCityIdByIp(Integer ip) {
//        // 这里请求去拿ip地址对应的位置 没有去详细做 直接返回1
//        return 2;
//    }

    @Override
    public List<Goods> getGoodsListsByPage(Integer page, Integer size, Integer cityId, Integer ip) {
        size = size > 20 ? 20 : size;
//        if (cityId == null) {
//            cityId = getCityIdByIp(ip);
//        }

        return goodsMapper.getGoodsListsByPage((page - 1) * size, size, cityId);
    }
}



